<?php

namespace app\admin\model;

use think\Model;

class HomePage extends Model
{
    private static $instance = null;

    public static function getInstance()
    {
        // 检测当前类属性$instance是否已经保存了当前类的实例
        if (self::$instance == null) {
            // 如果没有,则创建当前类的实例
            self::$instance = new self();
        }
        // 如果已经有了当前类实例,就直接返回,不要重复创建类实例
        return self::$instance;
    }

    public function getOne($where, $field = '*')
    {
        return $this->field($field)->where($where)->find();
    }

    public function getList($where, $field, $order = 'id')
    {
        return $this->field($field)->where($where)->order($order, 'desc')->select();
    }
}
